package com.example.controller;

import com.example.common.AjaxResult;
import com.example.dto.LoginUserDTO;
import com.example.vo.UserVo;
import com.example.entity.User;
import com.example.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Author：汤小洋
 * Date：2025-07-04 9:24
 * Description：<描述>
 */
@Api(tags = "01.用户接口")
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public AjaxResult register(@RequestBody User user){
        userService.register(user);
        return AjaxResult.success();
    }

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginUserDTO loginUserDTO){
        UserVo userVo = userService.login(loginUserDTO);
        return AjaxResult.success(userVo);
    }


}
